﻿namespace Tszy.Unlimited.Base.Exceptions;

/// <summary>
/// 主应用程序异常。
/// </summary>
public class MainApplicationException : ApplicationException
{
    /// <summary>
    /// 初始化应用程序异常。
    /// </summary>
    /// <param name="errorMessage">错误信息。</param>
    /// <param name="result">响应数据。</param>
    /// <param name="innerException">异常信息。</param>
    public MainApplicationException(string errorMessage, object? result = null, Exception? innerException = null)
        : this(0, errorMessage, innerException, result)
    {
    }

    /// <summary>
    /// 初始化应用程序异常。
    /// </summary>
    /// <param name="errorCode">错误码。</param>
    /// <param name="errorMessage">错误信息。</param>
    /// <param name="innerException">异常信息。</param>
    public MainApplicationException(int errorCode, string errorMessage, Exception? innerException)
        : this(errorCode, errorMessage, innerException, null)
    {
    }

    /// <summary>
    /// 初始化应用程序异常。
    /// </summary>
    /// <param name="errorCode">错误码。</param>
    /// <param name="errorMessage">错误信息。</param>
    /// <param name="innerException">异常信息。</param>
    /// <param name="result">响应数据。</param>
    public MainApplicationException(int errorCode, string errorMessage, Exception? innerException, object? result)
       : base(errorMessage, innerException)
    {
        ErrorCode = errorCode;
        Result = result;
    }

    /// <summary>
    /// 错误码。
    /// </summary>
    public int ErrorCode { get; protected set; }

    /// <summary>
    /// 响应数据。
    /// </summary>
    public object? Result { get; protected set; }
}